import 'dart:async';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:nft_shop/res/constant.dart';
import 'package:nft_shop/sift/index/index.dart';
import 'package:nft_shop/widgets/load_image.dart';

class SplashPage extends StatefulWidget {
  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin {

  bool isShow = false;

  @override
  void initState() {
    super.initState();

    Future.delayed(Duration(milliseconds: 2000), () {
      setState(() {
        isShow = true;
      });
      Future.delayed(Duration(milliseconds: 1000), () {
        Navigator.of(context).pushReplacementNamed(Constant.routeHome);
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: WillPopScope(
        onWillPop: () => Future.value(false),
        child:Container(
            width: double.infinity,
            height: double.infinity,
            decoration: BoxDecoration(
              gradient: LinearGradient(colors: [
                Color(0xFF022246),
                Color(0xFF03010C),
              ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
            ),
          child: Stack(fit: StackFit.expand, children: <Widget>[
            Align(alignment: Alignment.topCenter, child: Container(
              margin: const EdgeInsets.only(top: 40),
              child: Container(
                width: Get.width-170,
                height: Get.width-170,
                child: Stack(
                        children: [
                          LoadAssetImage("start2",width: Get.width-170,),
                          Align(alignment: Alignment.center,child: LoadAssetImage("start1",width:(Get.width-170)*100/368,))
                        ],
                      ),
              )
            )),
            Positioned(
              left: Get.width-350/2 + 20,
              child: Padding(
                padding: EdgeInsets.only(top: Get.width-170+40,),
                child: LoadAssetImage("start4",width: 350,),
              ),
            ),
            Positioned(
              left: -(250/2) - 20,
              bottom: 140,
              child: LoadAssetImage("start3",width: 250,),
            ),
            Visibility(
              visible: isShow,
              child: Align(alignment: Alignment.bottomCenter,child: Padding(
                padding: const EdgeInsets.only(bottom: 83),
                child: LoadAssetImage("footer_img",height: 30,),
              )),
            )

          ]),



        // child: Container(
        //   width: dou,
        //   decoration: BoxDecoration(
        //     gradient: LinearGradient(colors: [
        //       Color(0xFF03010C),
        //       Color(0xFF022246),
        //     ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
        //   ),
        //   child: Column(
        //     mainAxisSize: MainAxisSize.min,
        //     crossAxisAlignment: CrossAxisAlignment.center,
        //     children: [
        //       SizedBox(height: 10,),
        //       Container(width: 100,height: 100,color: Colors.red,),
        //       Stack(
        //         children: [
        //           LoadAssetImage("start2",width: 268,height: 268,),
        //           LoadAssetImage("start1",width: 98,height: 116,),
        //         ],
        //       )
        //     ],
        //   )
        //   ,
        ),
      ),
    );
  }
}

void nextPage(context) {
  // Get.offUntil(page IndexPage());
  // Navigator.of(context).pushReplacementNamed(RouteName.tab);
}
